from sklearn import datasets
from sklearn import ensemble
from sklearn2pmml import PMMLPipeline, sklearn2pmml
from sklearn.model_selection import train_test_split

# 加载Iris数据集
# iris = datasets.load_iris()
# X, y = iris.data, iris.target
#
# #print(X)
#
# # 划分数据集为训练集和测试集
# X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=1)
#
# # 创建随机森林模型
# model = ensemble.RandomForestClassifier(n_estimators=5, random_state=1)
#
# # 训练模型
# model.fit(X_train, y_train)
#
# # 创建PMMLPipeline对象
# # pipeline = PMMLPipeline([("classifier", model)])
#
# # 转换模型为PMML文件
# # sklearn2pmml(pipeline, "IrisModel.pmml", with_repr=True)
#
# res = model.predict([[6.3, 3.3, 4.7, 1.6]])
# print(res)